package subject_set.interview.Day11_25_baidu;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author haomin
 * @date 2022/11/25 19:34
 **/

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    public TreeNode(int val) {
        this.val = val;
    }
}
public class Test0 {
    public static int findMaxSize(TreeNode head) {
        if(head == null) return 0;
        Deque<TreeNode> q = new LinkedList<>();
        q.offer(head);
        int maxSize = 0;
        while(!q.isEmpty()) {
            int size = q.size();
            maxSize = Math.max(maxSize, size);
            for(int i = 0; i < size; ++i) {
                TreeNode cur = q.poll();
                if(cur.left != null) q.offer(cur.left);
                if(cur.right != null) q.offer(cur.right);
            }
        }
        return maxSize;
    }
}